<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/WEB-TAG/platForm.tld" prefix="PF"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<PF:basePath/>">
		<title>部署流程</title>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<jsp:include page="/WEB-FACE/conf/includeH.jsp"></jsp:include>
		<link rel="stylesheet" type="text/css"
			href="WEB-FACE/model/kindeditor/themes/default/default.css">
		<script type="text/javascript"
			src="WEB-FACE/model/kindeditor/kindeditor-all-min.js"></script>
		<script type="text/javascript"
			src="WEB-FACE/model/kindeditor/zh_CN.js"></script>
		<script type="text/javascript" src="PLUGIN/bpm/common/shCore.js"></script>
		<script type="text/javascript" src="PLUGIN/bpm/common/shBrushXml.js"></script>
		<link rel="stylesheet" type="text/css"
			href="PLUGIN/bpm/common/shCoreDefault.css">
	</head>
	<body class="easyui-layout">
		<div data-options="region:'north',border:false">
			<form id="dom_searchactreprocdef">
				<table class="editTable">
					<tr>
						<td class="title">
							流程名称:
						</td>
						<td>
							<input name="NAME_:like" type="text">
						</td>
						<td class="title">
							流程KEY:
						</td>
						<td>
							<input name="KEY_:like" type="text">
						</td>
						<td class="title">
							资源名称:
						</td>
						<td>
							<input name="RESOURCE_NAME_:like" type="text">
						</td>
					</tr>
					<tr style="text-align: center;">
						<td colspan="6">
							<a id="a_search" href="javascript:void(0)"
								class="easyui-linkbutton" iconCls="icon-search">查询</a>
							<a id="a_reset" href="javascript:void(0)"
								class="easyui-linkbutton" iconCls="icon-reload">清除条件</a>
						</td>
					</tr>
				</table>
			</form>
		</div>
		<div data-options="region:'center',border:false">
			<table class="easyui-datagrid" id="dom_datagridactreprocdef">
				<thead>
					<tr>
						<th data-options="field:'ck',checkbox:true"></th>
						<th field="CATEGORY_" data-options="sortable:false" width="80">
							分类
						</th>
						<th field="NAME_" data-options="sortable:false" width="200">
							名称
						</th>
						<th field="ID_" data-options="sortable:false" width="150">
							流程定义ID
						</th>
						<th field="KEY_" data-options="sortable:false" width="80">
							key
						</th>
						<th field="VERSION_" data-options="sortable:false" width="80">
							版本
						</th>
						<th field="DEPLOYMENT_ID_" data-options="sortable:false" width="80">
							部署ID
						</th>
						<th field="RESOURCE_NAME_" data-options="sortable:false" width="100">
							资源名称
						</th>
						<th field="NUM" data-options="sortable:false" width="80">
							实例数量
						</th>
						<th field="SUSPENSION_STATE_" data-options="sortable:false" width="80">
							流程定义状态
						</th>
						<th field="DESCRIPTION_" data-options="sortable:false" width="200">
							主题信息格式
						</th>
					</tr>
				</thead>
			</table>
		</div>
	</body>
	<script type="text/javascript">
	var url_delActionactreprocdef = "admin/ActReProcdefdeleteCommit.do";//删除URL
	var url_formActionactreprocdef = "admin/ActReProcdefshow.do";//增加、修改、查看URL
	var url_searchActionactreprocdef = "admin/ActReProcdefqueryAll.do";//查询URL
	var title_windowactreprocdef = "部署流程";//功能名称
	var gridactreprocdef;//数据表格对象
	var searchactreprocdef;//条件查询组件对象
	var TOOL_BARactreprocdef = [ {
		id : 'start',
		text : '激活',
		iconCls : 'icon-control-play',
		handler : startProcess
	},{
		id : 'stop',
		text : '暂停',
		iconCls : 'icon-control-stop',
		handler : stopProcess
	}, {
		id : 'view',
		text : '详细信息',
		iconCls : 'icon-product-design',
		handler : viewProcessdef
	}, {
		id : 'startermng',
		text : '流程启动者管理',
		iconCls : 'icon-group_green_edit',
		handler : startermng
	} , {
		id : 'del',
		text : '删除',
		iconCls : 'icon-remove',
		handler : delProcessdef
	}, {
		id : 'import',
		text : '导入流程定义XML',
		iconCls : 'icon-issue',
		handler : importProcessdef
	},{
		id : 'edit',
		text : '修改流程信息',
		iconCls : 'icon-edit',
		handler : editProcessdef
	}, {
		id : 'export',
		text : '导出流程定义XML',
		iconCls : 'icon-attibutes',
		handler : exportProcessdef
	}, {
		id : 'exportIdcode',
		text : '导出角色/人员/系统变量编码对照表',
		iconCls : 'icon-report',
		handler : exportIdreport
	} ];
	$(function() {
		//初始化数据表格
		gridactreprocdef = $('#dom_datagridactreprocdef').datagrid( {
			url : url_searchActionactreprocdef,
			fit : true,
			'toolbar' : TOOL_BARactreprocdef,
			pagination : true,
			closable : true,
			checkOnSelect : true,
			striped : true,
			rownumbers : true,
			ctrlSelect : true,
			fitColumns : false
		});
		//初始化条件查询
		searchactreprocdef = $('#dom_searchactreprocdef').searchForm( {
			gridObj : gridactreprocdef
		});
	});
	//导入
	function importProcessdef() {
		var url = "index/ActReProcdefImport.do" + '?pageset.pageType='
				+ PAGETYPE.ADD;
		$.farm.openWindow( {
			id : 'winactreprocdef',
			width : 600,
			height : 250,
			modal : true,
			url : url,
			title : '导入流程定义XML'
		});
	}
	//导出
	function exportProcessdef() {
		var selectedArray = $(gridactreprocdef).datagrid('getSelections');
		if (selectedArray.length == 1) {
			window.location = "admin/loadBpmXmlfile.do?ids="
					+ selectedArray[0].ID_;
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
		}
	}
	//导出ID对照表
	function exportIdreport() {
			window.location = "admin/downIdReport.do";
	}
	//导出系统变量对照表
	function exportVariables() {
			window.location = "admin/downVariableReport.do";
	}
	//查看
	function viewProcessdef() {
		var selectedArray = $(gridactreprocdef).datagrid('getSelections');
		if (selectedArray.length == 1) {
			var url = url_formActionactreprocdef + '?pageset.pageType='
					+ PAGETYPE.VIEW + '&ids=' + selectedArray[0].ID_;
			$.farm.openWindow( {
				id : 'winactreprocdef',
				width : 600,
				height : 300,
				modal : true,
				url : url,
				title : '详细信息'
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
		}
	}
	//管理流程启动者
	function startermng() {
		var selectedArray = $(gridactreprocdef).datagrid('getSelections');
		if (selectedArray.length == 1) {
			var url = "admin/ActReProcdef_Startermanager.do" + '?pageset.pageType='
					+ PAGETYPE.VIEW + '&ids=' + selectedArray[0].ID_;
			$.farm.openWindow( {
				id : 'winactreprocdef',
				width : 600,
				height : 300,
				modal : true,
				url : url,
				title : '流程启动者'
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
		}
	}
	
	//修改流程信息
	function editProcessdef() {
		var selectedArray = $(gridactreprocdef).datagrid('getSelections');
		if (selectedArray.length == 1) {
			var url = "index/ActReProcdefImport.do" + '?pageset.pageType='
					+ PAGETYPE.EDIT + '&ids=' + selectedArray[0].ID_;
			$.farm.openWindow( {
				id : 'winactreprocdef',
				width : 600,
				height : 300,
				modal : true,
				url : url,
				title : '修改流程信息'
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
		}
	}
	//暂停
	function stopProcess() {
		var selectedArray = $(gridactreprocdef).datagrid('getSelections');
		if (selectedArray.length == 1) {
			// 有数据执行操作
			var str = "该流程将被暂停，是否继续?";
			$.messager.confirm(MESSAGE_PLAT.PROMPT, str, function(flag) {
				if (flag) {
					$(gridactreprocdef).datagrid('loading');
					$.post("admin/ActReProcdefStop.do" + '?ids='
							+ $.farm.getCheckedIds(gridactreprocdef, "ID_"),
							{}, function(flag) {
								$(gridactreprocdef).datagrid('loaded');
								if (flag.pageset.commitType == 0) {
									$(gridactreprocdef).datagrid('reload');
								} else {
									var str = MESSAGE_PLAT.ERROR_SUBMIT
											+ flag.pageset.message;
									$.messager.alert(MESSAGE_PLAT.ERROR, str,
											'error');
								}
							});
				}
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
		}
	}
	//激活
	function startProcess() {
		var selectedArray = $(gridactreprocdef).datagrid('getSelections');
		if (selectedArray.length == 1) {
			// 有数据执行操作
			var str = "该流程将被激活，是否继续?";
			$.messager.confirm(MESSAGE_PLAT.PROMPT, str, function(flag) {
				if (flag) {
					$(gridactreprocdef).datagrid('loading');
					$.post("admin/ActReProcdefStart.do" + '?ids='
							+ $.farm.getCheckedIds(gridactreprocdef, "ID_"),
							{}, function(flag) {
								$(gridactreprocdef).datagrid('loaded');
								if (flag.pageset.commitType == 0) {
									$(gridactreprocdef).datagrid('reload');
								} else {
									var str = MESSAGE_PLAT.ERROR_SUBMIT
											+ flag.pageset.message;
									$.messager.alert(MESSAGE_PLAT.ERROR, str,
											'error');
								}
							});
				}
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
		}
	}
	//删除
	function delProcessdef() {
		var selectedArray = $(gridactreprocdef).datagrid('getSelections');
		if (selectedArray.length > 0) {
			// 有数据执行操作
			var str = selectedArray.length + MESSAGE_PLAT.SUCCESS_DEL_NEXT_IS;
			$.messager.confirm(MESSAGE_PLAT.PROMPT, str, function(flag) {
				if (flag) {
					$.post(url_delActionactreprocdef + '?ids='
							+ $.farm.getCheckedIds(gridactreprocdef, "ID_"),
							{}, function(flag) {
								if (flag.pageset.commitType == 0) {
									$(gridactreprocdef).datagrid('reload');
								} else {
									var str = MESSAGE_PLAT.ERROR_SUBMIT
											+ flag.pageset.message;
									$.messager.alert(MESSAGE_PLAT.ERROR, str,
											'error');
								}
							});
				}
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
		}
	}
</script>
</html>




